package com.quanjiaolian.userinfo.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.quanjiaolian.tools.ResponseToJson;
import com.quanjiaolian.userinfo.service.OrderInfoService;
import com.quanjiaolian.userinfo.serviceimpl.OrderInfoServiceImpl;
/**
 * 查看订单详情
 * @author Herson_Li
 *
 */
@SuppressWarnings("serial")
public class OrderDetail extends HttpServlet {
	/**
	 * 声明Log4j变量
	 */
	public static ResourceBundle resourceBundle = null;
	static Logger logger = Logger.getLogger(OrderDetail.class.getName());
	
	Map<String,Object> resultMap = new HashMap<String,Object>();
	OrderInfoService os = new OrderInfoServiceImpl();
	/**
	 * 根据订单编号查询订单详情(用户角色)
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try{
			String order_id = request.getParameter("order_id");
			Map<String,Object> map = os.queryUserOrderDetail(order_id);
			if(map.size() == 0 || map == null){
				resultMap.put("result","no result");
			}else{
				resultMap.put("result",map);
			}
		}catch (Exception e) {
			resultMap.put("result","Error");
			logger.info(e);
		}
		ResponseToJson.responseOutWithJson(response,resultMap);
		
	}

	/**
	 * 根据订单编号查询订单详情(教练角色)
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try{
			String order_id = request.getParameter("order_id");
			Map<String,Object> map = os.queryInsOrderDetail(order_id);
			if(map.size() == 0 || map == null){
				resultMap.put("result","no result");
			}else{
				resultMap.put("result",map);
			}
		}catch (Exception e) {
			resultMap.put("result","Error");
			logger.info(e);
		}
		ResponseToJson.responseOutWithJson(response,resultMap);
		
	}

}
